import request from "@/utils/request.ts";
import {CheckCaptchaRes,DoConfirmOrderParams,DoConfirmOrderRes,QueryLineCountRes} from "@/api/order/type.ts";

/**
 * captcha
 * @param {string} uuid
 * @returns
 */
export function captcha(uuid: string): string {
    return import.meta.env.VITE_SERVE+`/business/captcha/createCaptcha/${uuid}`;
}

/**
 * checkCaptcha
 * @param {string} uuid
 * @param {string} code
 * @returns
 */
export function checkCaptcha(uuid: string, code: string): Promise<CheckCaptchaRes> {
    return request.get(`/business/captcha/checkCaptcha/${uuid}?code=${code}`);
}

/**
 * doConfirmOrder
 * @param {object} params ConfirmOrderDoReq
 * @param {number} params.id
 * @param {number} params.memberId
 * @param {object} params.date
 * @param {string} params.trainCode
 * @param {string} params.start
 * @param {string} params.end
 * @param {number} params.dailyTrainTicketId
 * @param {array} params.tickets
 * @param {string} params.status
 * @param {object} params.createTime
 * @param {object} params.updateTime
 * @returns
 */
export function doConfirmOrder(params: DoConfirmOrderParams): Promise<DoConfirmOrderRes> {
    return request.post(`/business/confirm-order/do`, params);
}

/**
 * queryLineCount
 * @param {string} id
 * @returns
 */
export function queryLineCountReq(id: number): Promise<QueryLineCountRes> {
    return request.get(`/business/confirm-order/query-line-count/${id}`);
}